<form id="form-project" class="form-horizontal" action="/admin/setting/project" method="post" accept-charset="utf-8">
    {% raw xsrf_form_html() %}
    <div class="form-group">
        <label for="project" class="col-md-2 col-lg-1 control-label">项目名称:</label>
        <div class="col-md-4 col-lg-2">
            <input type="text" id="project" name="project" class="form-control"
                   required data-toggle="popover" data-target="manual" data-placement="top">
        </div>
        <div class="col-md-2 col-lg-1">
            <input type="submit" value="添加" class="btn btn-primary">
        </div>
    </div>
</form>
<div class="table-responsive">
    <table class="table table-striped table-hover">
        <thead>
        <tr>
            <th>#</th>
            <th class="col-md-3 col-lg-2">项目名称</th>
            <th>可访问项目成员</th>
            <th>状态</th>
            <th class="col-md-3">操作</th>
        </tr>
        </thead>
        <tbody>
        {% for i in range(len(lists)) %}
        <tr>
            <td>{{ (page-1)*limit+i+1 }}</td>
            <td>{{ lists[i].name }}</td>
            <td>{{ lists[i].user }}</td>
            <td>
                {% if lists[i].status == 1 %}
                <span class="label label-primary">已启用</span>
                {% else %}
                <span class="label label-warning">已禁用</span>
                {% end %}
            </td>
            <td>
                <a class="btn btn-primary project-user" data-pid="{{ lists[i].id }}" data-name="{{ lists[i].name }}">成员管理</a>&nbsp;&nbsp;
                <a class="btn btn-primary project-param" data-pid="{{ lists[i].id }}" data-name="{{ lists[i].name }}">参数配置</a>&nbsp;&nbsp;
                {% if lists[i].status == 1 %}
                <a class="btn btn-danger btn-enable" data-pid="{{ lists[i].id }}" data-status="0">禁用</a>
                {% else %}
                <a class="btn btn-info btn-enable" data-pid="{{ lists[i].id }}" data-status="1">启用</a>
                {% end %}&nbsp;&nbsp;
                {% if current_user.role != 2 %}
                <a class="btn btn-danger btn-delete" data-id="{{ lists[i].id }}">删除</a>
                {% end %}
            </td>
        </tr>
        {% end %}
        </tbody>
    </table>
    {% module nav(total_page, page, limit, '/admin/setting/project/{}'.format(pid)) %}
</div>
<div class="modal fade" id="project-user" tabindex="-1" role="dialog" aria-labelledby="addLabel">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="addLabel">项目成员管理</h4>
            </div>
            <form class="form-horizontal" action="/admin/setting/project/adduser" method="post" accept-charset="utf-8">
            {% raw xsrf_form_html() %}
                <div class="modal-body">
                    <div class="form-group">
                        <label for="project-name" class="col-md-offset-1 col-md-2 control-label" style="text-align:left;">所属项目:</label>
                        <div class="col-md-4">
                            <label id="project-name" class="control-label"></label>
                            <input type="hidden" id="project-id" name="project_id">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="project-add-user" class="col-md-offset-1 col-md-2 control-label" style="text-align:left;">请选择成员:</label>
                        <label for="project-cur-user" class="col-md-offset-4 col-md-2 control-label" style="text-align:left;">已选择成员:</label>
                        <label class="col-md-offset-2 control-label">发邮件</label>
                    </div>
                    <div class="form-group">
                        <div class="col-md-offset-1 col-md-4">
                            <select id="project-add-user" style="height:500px" class="form-control" multiple>
                            </select>
                        </div>
                        <div class="col-md-2">
                            <div style="margin-top:200px;">
                                <p>双击选择成员&nbsp;&gt;&gt;&gt;</p>
                                <p style="margin-top:40px;">&lt;&lt;&lt;&nbsp;双击移除成员</p>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <select id="project-cur-user" style="height:500px" name="project_users" class="form-control" multiple>
                            </select>
                        </div>
                        <div id="send-mail">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <input type="button" id="submit-btn" class="btn btn-primary" data-dismiss="modal" value="保存">
                </div>
            </form>
        </div>
    </div>
</div>
<div class="modal fade" id="project-param" tabindex="-1" role="dialog" aria-labelledby="paramLabel">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="paramLabel">项目自定义参数配置</h4>
            </div>
            <form class="form-horizontal" action="/admin/setting/project/addparam" method="POST" accept-charset="utf-8">
            {% raw xsrf_form_html() %}
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-md-2 control-label">所属项目</label>
                        <div class="col-md-4">
                            <label class="control-label project-name"></label>
                            <input type="hidden" name="project_id">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-2">变量类型</label>
                        <div class="col-md-2">
                            <select name="type" class="form-control">
                                <option selected>String</option>
                                <option>Function</option>
                                <option>Data</option>
                            </select>
                        </div>
                        <div class="col-md-2">
                            <input type="text" name="name" class="form-control" required placeholder="变量名">
                        </div>
                        <div class="col-md-4">
                            <input type="text" name="value" class="form-control" required placeholder="变量值">
                        </div>
                        <div class="col-md-1">
                            <span class="control-label glyphicon glyphicon-plus" aria-hidden="true"></span>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <span class="label label-info sr-only" style="font-size:14px;" id="msg"></span>
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <input type="button" id="param-submit-btn" class="btn btn-primary" value="保存">
                </div>
            </form>
            <div class="sr-only" data-param="Function">
                <select name="value" class="form-control">
                    <option value="" selected>请选择自定义方法</option>
                    {% for f in customs_func %}
                    <option data-toggle="tooltip" data-placement="right" title="{{ f['comment'] }}" value="{{ f['name'] }}">{{ f['name'] }}</option>
                    {% end %}
                </select>
            </div>
        </div>
    </div>
</div>